# Every update requires an update of these hashes and the version within the control file of each of the 32 ports.
# So it is probably better to have a central location for these hashes and let the ports update via a script
set(QT_MAJOR_MINOR_VER 5.15)
set(QT_PATCH_VER 14)
set(QT_UPDATE_VERSION OFF) # Switch to update qt and not build qt. Creates a file cmake/qt_new_hashes.cmake in qt5-base with the new hashes.

set(QT_PORT_LIST base 3d activeqt charts connectivity datavis3d declarative gamepad graphicaleffects imageformats location macextras mqtt multimedia networkauth
                 purchasing quickcontrols quickcontrols2 remoteobjects script scxml sensors serialport speech svg tools virtualkeyboard webchannel websockets
                 webview winextras xmlpatterns doc x11extras androidextras translations serialbus webengine webglplugin wayland)

set(QT_HASH_qt5-3d               502d80fddbf8d3ba18dd262c85df04abf6aa2ee76ba3eb10666588872635497a2828f34963945662b54ac9552d63e0463061d2065c34fdf8a7ea78d0871ebb2e)
set(QT_HASH_qt5-activeqt         ebef84c37875ab2deaf3931664527afce1e433984e8dda6036b244d29f3e561a3f1d8c948d45100658a34fca4ff098f885e53af14de68e260afc6070d1a48dc5)
set(QT_HASH_qt5-androidextras    e08080a88f7dd96fec59359fe109ab3f85916f2d8c7f6b7a441fc787514dfa64ec33c346764b2d8bbe71baf883291e73642909c5480144dacf0851282e0a9bca)
set(QT_HASH_qt5-base             1280e7da926ff0c888dc3455ebeb73708bf8e44a3fe77ecf015e902608d75d7304639271dedba63635f959411452cd2b64a6f9166365a3aa3440656c00120272)
set(QT_HASH_qt5-charts           1deee169cf86bef6d92b0cc1000106e84cbbe2ccb93729e299a94e794bcc6d882e1818b1b74ddb0b2f2b7427a4dfe556218dd9988c9b31888c21907f6d1efaf3)
set(QT_HASH_qt5-connectivity     a327711dcbe8d45e33732055784246ea23399aac8efecf23500709a16caabc61cc586fd21ab385573f0cc9d5a2da39de426fd882cf2c4c07bdf8c60c683d8388)
set(QT_HASH_qt5-datavis3d        b1778a2a1124caa01ec931d2c018f79a6810b8931a40a1ee7889acb0f9a47fb0d6547375f0dd3435009359be73e873a2acfe16fac918bb17b9f99a55094efca3)
set(QT_HASH_qt5-declarative      06c48938c5ab96c4a9e010fdf4a8fbf2b84b7669a486298044363048de3b7da01aa5d9284d1b08b563331887e326befb25566f9972f5143ca3cde47016394bbd)
set(QT_HASH_qt5-doc              ac670058501cc7732bb3d83038cb2862149ddd115d636412e95e0c8362000e38aa6eddc0ec71d4c34cea94fbf10c56ad074f790471b452e1c8ac7a6201e1223c)
set(QT_HASH_qt5-gamepad          a6fffbf01fd9e022949c99e926c9f877e9802b61e9517f36a574e90b60c3cb045061907114c6aaed1da0d2d068758617931ca123facd79ead9bae3b445174e26)
set(QT_HASH_qt5-graphicaleffects 774411e6fdcec6e91fa2368d4e8d0326581c638daad0b5b9fb7bba210fad854e51fe59555ccabf9bd331f601d93e8c5e3652095daa993dbc74b205db4b46e506)
set(QT_HASH_qt5-imageformats     8b9994b7e31a941ee265958da3829240bea89662d70f0e8ded7fb0cf354d4f6a38bd16664c32a97ae73424dc9ac853b24c0b6a645e20f8c39177e26fc1d43f2e)
set(QT_HASH_qt5-location         5a6271d61bb9ede80b8483e784d8cc15170cf3f7b019472b2362c742e1e1fd52d811c2132b751574dacee6f7274b81e6049b8a3dc934ba7612c0aef6643062dd)
set(QT_HASH_qt5-macextras        70275814cbf9f9d3c4a4aa10d9d526a4082f892fdec95de10e8eeaf87b7aa0d29cc7881882039a8a0cd8b1dd09faac071be73e80923aff89c1193efe2e52291a)
set(QT_HASH_qt5-mqtt             ac99b314e6223158e946a798c6c937f6f5f5541b6a574f7e35626f93cda808c8368b26fe2d8e564c1160d5d40cf87afd28d715684c8e9d35b87e4a33bebe9f0e)
set(QT_HASH_qt5-multimedia       6059bd9aec65888ed6f3a1f87506a94ea567f9e064bb4a586859bc8f76ee4dca573eb256623452ddd9daf2305f49c707673425ea08edca9cd2db7b56bf5cab9c)
set(QT_HASH_qt5-networkauth      e0315df81f7ee6da7798212ac18b2e5b7936f5ec355c089f2c095bc8edd5f59cdb68c0bfec300dad30f62f4444549cfe19c5b5fe14943328064da7416cbf5f00)
set(QT_HASH_qt5-purchasing       d916c404ac73a9e8a063e103c3e850bd015dc16cd860d7abf8f7cae5107dbf1e87d5f784bd7f07737a0c4224640fbaeaa4a38eaaf697810404850bb877b92fb0)
set(QT_HASH_qt5-quickcontrols    1fdfda2cd1922801dc59c0cae8dfcd3e7e342cc820e092921a7c1e40123740c527df1777209b90109ad277cac47964c40a30ad1a5d4184b9283c015c91d43ce3)
set(QT_HASH_qt5-quickcontrols2   acf6a03086fd840e13eafda20e8aef3803edfdd90ea9932e9ef8ef3c1f029375010624b1ce2b8f1386c1f0dcf08c1abc86182ceec8a00f480f1cef13e8b693cf)
set(QT_HASH_qt5-remoteobjects    78942dd10d39352850677b383eca93fb74170b5a5c037b4db1fea1a17002009ad62f0310a711accde1193535dedf5eff01c5e14b088590d91b62ba4c7dc4999e)
set(QT_HASH_qt5-script           b1b5e700be35e9c063e15f2a53b97a78368642d3287dea67cc4f97a049cc6ffa1a9a39da61ac49608cfeac435215c544a6cd80d67da673fd16f341f2aa0628e1)
set(QT_HASH_qt5-scxml            1490824b0108300b1924f404431e3871ce067def15993aed9af768c871b3d0eae4cd0b8f467671d3ebcada98d5e11dfe86e250467b7dbf9708ce9f37766861d5)
set(QT_HASH_qt5-sensors          777882f3bf3ddbfe053132f123c14590538fdf483479877779cfdd3dc242021d86aedc6484a453b67282f1ba4447c73e4f7a04bf3d4b741789b37e646ab67f35)
set(QT_HASH_qt5-serialbus        ac30e163fd2ef7a3d6dbb8f8f3cac06d68f915d29c87d1d49be541c38c3dd09873d89525508062b7cf6dc17d750167e0cc13bb48718f2a42b80b2e7f04e7633d)
set(QT_HASH_qt5-serialport       64980191cf8bc27a7a28bc8d373f1ee4d16bec5ab6b1e3296d4bc245498bb59d29bec49ebe609f8242bffb205f923acff7ab736f80d01d7689032896ee8f9bad)
set(QT_HASH_qt5-speech           87d021efb5d07704dd5469bb3050e9381e8da47d2ef41bd37a95ac1903410b781283af42694dd1300c84bd0f0ea219e61da0a3aaf6204937578d26044a297f79)
set(QT_HASH_qt5-svg              4f781bddaae619125fc0f73b5736eb33dc49f368cc9cab9fce436cb57b389e66d14d2625e9100c2c1d809b67c3ceb16f718f50ce4abe1c925cf8dc8bb8b285a8)
set(QT_HASH_qt5-tools            c936ed67a7c5d36fadf55ab8ebb9d22d6697a86b34b1c162f472341de31fa14fc2a3116b50d847d46ba953dab0231eae8131634c4ad0dfd4009b7d7f9ba960ae)
set(QT_HASH_qt5-translations     bf41fea921151c10f78804e274919805ccee12c13c57fe50e8f6df863aa955e4a1aa939d23a7500cd3b5fe6aa5656b1a12628cdbed1e9c8dc1f126e2cf7d7176)
set(QT_HASH_qt5-virtualkeyboard  d6ff2770282e460a8d9fff3746225918cb21c65ef0d0d89e1c6876428ca1e860ecf45b44d57c9ef6e9a85cb050a4a67ecc1b20ae5c5be0a37d8b73ca439587c3)
set(QT_HASH_qt5-wayland          9e8add52353f7a146759511c49c001cd76a56790a81af5222f6f2d3d1a2f1ee9cc62048c72efe69708eb3444c6115272d4af8d738df7b1e1da959359d7420dbb)
set(QT_HASH_qt5-webchannel       8b87f73a256dff16ec8de226b10d8a34d9a1c4f1c2d510ea58824558f3b188a3a4d66c4507764b713407f44a0861e96d061fd164a1a050129fcf4148efd3999f)
set(QT_HASH_qt5-webengine        be25e76518346b0059f3331bee786fa6ba7551931794d29a59d5cc3b9f80863f9da47bf5a91f749ba7dbfae037040b4bad4f48ef40f70a188186645923550c0c)
set(QT_HASH_qt5-webglplugin      1b4d9ac16653f4e64b2c2838b4677b554b8ca1c6cbff1632a1f65f2edc4a7f925b850b2e71e2fcbd2d63f8de170887f191112ca365f0bce2e9d6c86ac8687282)
set(QT_HASH_qt5-websockets       bfd3738a9bdf51dd4534c2341c20e3918a1183ca3f4307de5c2fd7224dfcc890162530e7d8c67ceed9ca56c2c9d15d4c80355e65c4e5a41bd7f7ce4d3b072b1b)
set(QT_HASH_qt5-webview          5a48688439a8d4eaa13c4a5c8453e6a399413d28a8cbdcb1d04a4723b9a0a527d64c2c48bc040cf960300335db958add05a63fb39a6a94fbe1ad19f4989864f6)
set(QT_HASH_qt5-winextras        7383843f65ba5b9a3fd20f34fbbfbb89c847fcfa05d4a948360f072b148d2eff2543c4fb1df48bf695504a01a843224a5d89c83bbb2acb6d9145e1ee11397edc)
set(QT_HASH_qt5-x11extras        32825110fb272b03cda432c25ca26eb645685d2c70beaf10045256cfc2837c64307d2475c8dabc7daeb4e19341e282d23cb4a1579fddaf17853525ad232d55f1)
set(QT_HASH_qt5-xmlpatterns      a9c46ffd6c13221d981d4a5b3cb31cdcdd8250fbe11262c1778815e83892d8c299e4c78b2cf31f7c33eb573e38c8e18255d501c8b95e809d877e2c981a6e7c8a)

if(QT_UPDATE_VERSION)
    message(STATUS "Running Qt in automatic version port update mode!")
    set(_VCPKG_INTERNAL_NO_HASH_CHECK 1)
    if("${PORT}" MATCHES "qt5-base")
        function(update_qt_version_in_manifest _port_name)
            set(_current_control "${VCPKG_ROOT_DIR}/ports/${_port_name}/vcpkg.json")
            file(READ ${_current_control} _control_contents)
            #message(STATUS "Before: \n${_control_contents}")
            string(REGEX REPLACE "\"version.*\": \"[0-9]+\.[0-9]+\.[0-9]+\",\n" "\"version\": \"${QT_MAJOR_MINOR_VER}.${QT_PATCH_VER}\",\n" _control_contents "${_control_contents}")
            string(REGEX REPLACE "\n  \"port-version\": [0-9]+," "" _control_contents "${_control_contents}")
            #message(STATUS "After: \n${_control_contents}")
            file(WRITE ${_current_control} "${_control_contents}")
            configure_file("${_current_control}" "${_current_control}" @ONLY NEWLINE_STYLE LF)
        endfunction()

        update_qt_version_in_manifest("qt5")
        foreach(_current_qt_port_basename ${QT_PORT_LIST})
            update_qt_version_in_manifest("qt5-${_current_qt_port_basename}")
        endforeach()
    endif()
endif()
